<?php


namespace App\Model;


use Illuminate\Database\Eloquent\Model;

class WithdrawLog extends Model
{
    const CREATED_AT = 'createtime';
    const UPDATED_AT = null;

    //表名
    protected $table = 'withdraw_log';

    // 追加属性
    protected $appends = [
        'status_text'
    ];

    public function getWithdrawPriceAttribute($value)
    {
        return bcdiv($value, 100, 2);
    }

    protected function setWithdrawPriceAttribute($value)
    {
        return bcmul($value, 100, 0);
    }

    public function getStatusTextAttribute()
    {
        $value = $this->status;
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getStatusList()
    {
        return [1 => '审核中', 2 => '打款中', 3 => '提现成功'];
    }

    /**
     * 关联收款账户表
     */
    public function collectAccount()
    {
        return $this->belongsto('App\Model\CollectAccount', 'account_id', 'id', '')->select('id', 'account_name');
    }
}
